﻿@using KL.Store.Core;
@using CaptchaMvc.HtmlHelpers;
@{
    Layout = "~/Views/Shared/_LayoutBasic.cshtml";
    ViewBag.Title = "Edit";
    //Html.EnableClientValidation(false);
    var ToEdit = ViewBag.ToEdit;
}
<div id="processResult"></div>
<h2 style="display: inline-block;">Ürün Yönetimi</h2>
@{Html.RenderAction("EditMenu", "ProductManage", new { id = ViewBag.id, toEdit = ToEdit });}
<br />
@if (ToEdit != "AddNewProduct")
{
    Html.RenderAction("VariantProductsList", "ProductManage", new { id = ViewBag.id, toEdit = ToEdit });
    <div class="right">@(ViewBag.id) - @(ViewBag.ProductName + (!string.IsNullOrEmpty(ViewBag.Model) ? " - " + ViewBag.Model : ""))</div>
    <div class="clearfix"></div>
}
<hr />
@if (ToEdit == "EditInfo")
{
    Html.RenderAction("EditInfo", "ProductManage", new { id = ViewBag.id });
}

@if (ToEdit == "ClearCacghe")
{
    Html.RenderAction("ClearCache", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "EditImages")
{
    Html.RenderAction("EditImages", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "EditGroups")
{
    Html.RenderAction("EditGroups", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "EditProperties")
{
    Html.RenderAction("EditProperties", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "EditVariant")
{
    Html.RenderAction("EditVariant", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "EditLinked")
{
    Html.RenderAction("EditLinked", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "EditMeta")
{
    Html.RenderAction("EditMeta", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "AddNewProduct")
{
    Html.RenderAction("AddNewProduct", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "EditStok")
{
    Html.RenderAction("EditStok", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "EditStockPrices")
{
    Html.RenderAction("EditStockPrices", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "EditXmlImport")
{
    Html.RenderAction("EditXmlImport", "ProductManage", new { id = ViewBag.id });
}
else if (ToEdit == "DeleteProduct")
{
    Html.RenderAction("DeleteProduct", "ProductManage", new { id = ViewBag.id });
}

<script>

    function loadingMsg() {
        $('#processResult').show(0).html('<div class="bg-info loadingMsg"><p><i class="fa fa-spinner fa-spin"></i>&nbsp;Lütfen bekleyin.</p></div>');
    }
    function hideMsg() {
        $('#processResult').hide(0).html('');
    }
    function urunKaydedildi(yenileme) {
        $('#processResult').show(0).html('<div class="bg-info"><p><i class="fa fa-info-circle"></i>&nbsp;Bilgiler Kaydedildi</p></div>').delay(5000).hide(0);
        if ($.browser.webkit) {
            $('body:not(:animated)').animate({ scrollTop: 0 }, 'slow');
        }
        else {
            $('html:not(:animated)').animate({ scrollTop: 0 }, 'slow');
        }
        if (yenileme == '1') {
            parent.$.fancybox.close();
            parent.location.reload(true);
        }
    }
    function hataMesaji(mesaj) {
        $('#processResult').show(0).html('<div class="bg-danger"><p><i class="fa fa-info-circle"></i>&nbsp;' + mesaj + '.</p></div>');
        if ($.browser.webkit) {
            $('body:not(:animated)').animate({ scrollTop: 0 }, 'slow');
        }
        else {
            $('html:not(:animated)').animate({ scrollTop: 0 }, 'slow');
        }
    }
    $('#closeForm').click(function () {
        parent.$.fancybox.close();
    });
    $('#productedit').bind("keyup keypress", function (e) {
        var code = e.keyCode || e.which;
        if (code == 13) {
            e.preventDefault();
            return false;
        }
    });
    $('#processResult').click(function () {
        $(this).fadeOut('slow').html('');
    });
    function KapatVeYenile() {
        parent.$.fancybox.close();
        parent.location.reload(true);
    }
</script>
